import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
//class MountBaseRenderer
    
    export  class MountBaseRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this._lockBitmap = GlobalClass.getBitmap("Mounts_Lock");
            this.initView();
            return;
        }

        protected initView(): void
        {
            var loc1=GlobalClass.getBitmap("PackItemBg");
            loc1.x = 2;
            loc1.y = 2;
            addChild(loc1);
            this._picBitmap = new Object /* flash.display.Bitmap */();
            this._picBitmap.x = 4;
            this._picBitmap.y = 4;
            this.mouseChildren = false;
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1 && _data && !(_data is Boolean)) 
            {
                this.filters = [new Object /* flash.filters.GlowFilter */()];
            }
            else 
            {
                this.filters = null;
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (arg1.hasOwnProperty("isLock")) 
            {
                this.isLock = arg1.isLock as Boolean;
            }
            return;
        }

        protected load(arg1: string): void
        {
            LoaderManager.instance.load(arg1, this.onPicLoad);
            return;
        }

        protected onPicLoad(arg1: ImageInfo): void
        {
            if (arg1 && arg1.bitmapData) 
            {
                this._picBitmap.bitmapData = arg1.bitmapData;
                this._picBitmap.width = 36;
                this._picBitmap.height = 36;
            }
            if (!this.contains(this._picBitmap)) 
            {
                this.addChild(this._picBitmap);
            }
            return;
        }

        protected set isLock(arg1: Boolean)
        {
            if (arg1) 
            {
                if (!this.contains(this._lockBitmap)) 
                {
                    this._lockBitmap.x = (this.width - this._lockBitmap.width) / 2 + 2;
                    this._lockBitmap.y = (this.height - this._lockBitmap.height) / 2 + 2;
                    this.addChild(this._lockBitmap);
                }
                if (this.contains(this._picBitmap)) 
                {
                    removeChild(this._picBitmap);
                }
            }
            else 
            {
                if (this.contains(this._lockBitmap)) 
                {
                    this.removeChild(this._lockBitmap);
                }
                if (!this.contains(this._picBitmap)) 
                {
                    addChild(this._picBitmap);
                }
            }
            return;
        }

        protected /* var */_lockBitmap: Object /* flash.display.Bitmap */;

        protected /* var */_picBitmap: Object /* flash.display.Bitmap */;
    }
